/*
 * @Author: your name
 * @Date: 2022-04-11 13:57:21
 * @LastEditTime: 2022-04-13 15:17:22
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \blog-vue3\src\global\utils\mixins.js
 */
import Sortable from 'sortablejs';

export const mixins = {
    methods: {
        /**
         * 行拖拽
         */
        rowDrop() {
            const tbody = document.querySelector('.el-table__body-wrapper tbody');
            const _this = this;

            new Sortable(tbody, {
                animation: 150,
                onEnd({ newIndex, oldIndex }) {
                    const currRow = _this.table.list.splice(oldIndex, 1)[0];
                    _this.table.list.splice(newIndex, 0, currRow);
                }
            });
        }
    }
};